package br.com.doclayer.cmis;

import java.util.Date;

import org.apache.chemistry.opencmis.client.api.Document;

import br.com.doclayer.ContentMetadata;

/**
 * @author helder
 * @author glauco
 * 
 */
public class ContentCMISImpl implements ContentMetadata {

  @Override
  public String toString() {
    return "ContentCMISImpl [UUID=" + this.uuid + ", name=" + this.name
        + ", mimeType=" + this.mimeType + ", createdBy=" + this.createdBy
        + ", creationDate=" + this.creationDate + ", lastModifiedBy="
        + this.lastModifiedBy + ", lastModificationDate="
        + this.lastModificationDate + ", size=" + this.size + "]";
  }

  private String uuid;
  private String name;
  private String mimeType;
  private String createdBy;
  private Date creationDate;
  private String lastModifiedBy;
  private Date lastModificationDate;
  private long size;

  public ContentCMISImpl(Document document) {
    this.uuid = document.getId();
    this.name = document.getName();
    this.mimeType = document.getContentStreamMimeType();
    this.createdBy = document.getCreatedBy();
    this.creationDate = document.getCreationDate().getTime();
    this.lastModifiedBy = document.getLastModifiedBy();
    this.lastModificationDate = document.getLastModificationDate().getTime();
    this.size = document.getContentStreamLength();
  }

  @Override
  public String getUuid() {
    return this.uuid;
  }

  @Override
  public String getName() {
    return this.name;
  }

  @Override
  public String getCreatedBy() {
    return this.createdBy;
  }

  @Override
  public Date getCreationDate() {
    return this.creationDate;
  }

  @Override
  public String getLastModifiedBy() {
    return this.lastModifiedBy;
  }

  @Override
  public Date getLastModificationDate() {
    return this.lastModificationDate;
  }

  @Override
  public String getMimeType() {
    return this.mimeType;
  }

  @Override
  public long getSize() {
    return this.size;
  }

}
